package nl.utwente.csc.obsl.diagram.extension;

import org.eclipse.draw2d.IFigure;
import org.eclipse.draw2d.XYLayout;
import org.eclipse.gef.DragTracker;
import org.eclipse.gef.Request;
import org.eclipse.gmf.runtime.gef.ui.figures.NodeFigure;
import org.eclipse.gmf.runtime.notation.View;
import org.eclipse.sirius.diagram.ui.edit.api.part.AbstractNotSelectableShapeNodeEditPart;
import org.eclipse.sirius.diagram.ui.edit.api.part.IStyleEditPart;
import org.eclipse.sirius.diagram.ui.tools.api.figure.AirStyleDefaultSizeNodeFigure;
import org.eclipse.sirius.ui.tools.api.color.VisualBindingManager;

public abstract class OBSLEditPart extends
		AbstractNotSelectableShapeNodeEditPart implements IStyleEditPart{

	protected IFigure primaryShape;

	public OBSLEditPart(View view) {
		super(view);
	}

	public DragTracker getDragTracker(Request request) {
		return getParent().getDragTracker(request);
	}

	protected void createDefaultEditPolicies() {
	}

	public IFigure getContentPane() {
		if (primaryShape != null) {
			return primaryShape;
		}
		return super.getContentPane();
	}
	
	protected NodeFigure createNodeFigure() {
		NodeFigure figure = new AirStyleDefaultSizeNodeFigure(getMapMode()
				.DPtoLP(120), getMapMode().DPtoLP(40));
		figure.setLayoutManager(new XYLayout());
		IFigure shape = createOBSLFigure();
		shape.setBackgroundColor(VisualBindingManager.getDefault().getColorFromName("light_green"));
		shape.setForegroundColor(VisualBindingManager.getDefault().getColorFromName("black"));
		figure.add(shape);
		primaryShape = figure;
		return figure;
	}
	
	protected abstract IFigure createOBSLFigure();

}